package edu.langnan.xiaoli.controller.common;

import edu.langnan.xiaoli.base.AjaxResult;
import edu.langnan.xiaoli.base.controller.BaseController;
import edu.langnan.xiaoli.constant.XiaoLiConstants;
import edu.langnan.xiaoli.core.dto.CarPoolDTO;
import edu.langnan.xiaoli.core.page.TableDataInfo;
import edu.langnan.xiaoli.service.CarPoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author cql
 */
@RestController
@RequestMapping("common/car")
public class CommonCarPoolController extends BaseController {

    @Autowired
    private CarPoolService carPoolService;

    /**
     * 分页查询 pageNum,pageSize,orderByColumn,isAsc
     *
     * @param place 模糊查询
     * @return
     */
    @GetMapping("list")
    public TableDataInfo carpoolList(@RequestParam(value = "place", defaultValue = "",required = false) String place) {
        startPage();
        List<CarPoolDTO> result = carPoolService.carpoolList(place, XiaoLiConstants.EMPTY_STATUS, XiaoLiConstants.EMPTY_STU_ID);
        return getDataTable(result);
    }

    @GetMapping("{carpoolId}")
    public AjaxResult findCarPoolById(@PathVariable("carpoolId") Integer carpoolId) {
        CarPoolDTO carPoolDTO = carPoolService.findCarPoolById(carpoolId);
        return AjaxResult.success(carPoolDTO);
    }

}
